package data.visu.utils;

/**
 * @author Charles Perin
 * 29 mars 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 *
 */
public class StringFormater {

	public static String formatString(String s, int nbLetters){
		String res=s;
		if(s.length()>nbLetters){
			res = cutString(s, nbLetters);
			res = "<html><center>"+res+"<center><html>";
		}
		return res;
	}
	
	private static String cutString(String s, int nbLetters){
		String start="", end="";
		if(s.length()> nbLetters){
			start = s.substring(0,nbLetters);
			end = s.substring(nbLetters);
			end = cutString(end, nbLetters);
		}
		else end = s;
		if(end.startsWith("-<br>"))end = end.substring(5);
		return start+"-<br>"+end;
	}
}
